﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PokeIn.Comet;
using System.Net;

public partial class MasterPage : System.Web.UI.MasterPage
{
    bool IsAuthenticated;
    String userName;
    protected void Page_Load(object sender, EventArgs e)
    {
        //You must define a listener for below event
        if (Request.IsAuthenticated)
        {
            IsAuthenticated = true;
            userName = HttpContext.Current.User.Identity.Name;
        }
        else
        {
            IsAuthenticated = false;
        }
        CometWorker.OnClientConnected += new DefineClassObjects(CometWorker_OnClientConnected);
    }

    void CometWorker_OnClientConnected(ConnectionDetails details, ref Dictionary<string, object> classList)
    {
        if (IsAuthenticated)
        {
            classList.Add("MyClients", new MyClients(userName));
        }
    }
}
